package com.bjbn.controller;

import com.alibaba.fastjson.JSONObject;
import com.bjbn.bean.ApiCallParams;
import com.bjbn.bean.ApiResult;
import com.bjbn.service.DataphinService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 机坪融合指挥系统API
 */
@RestController
@RequestMapping("/dataphin")
@Slf4j
public class Dataphin4ApronApiController {

    @Autowired
    DataphinService dataphinService;

    /**
     * 停机位表
     * @param orderByList
     * @param pageStart
     * @param pageSize
     * @return
     */
    @RequestMapping("/data_twin_ads_acis_apron_bay_df")
    public JSONObject ads_acis_apron_bay_df(@RequestParam(required = false, defaultValue = "") String orderByList,
                                           @RequestParam(required = false, defaultValue = "1") Integer pageStart,
                                           @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        String fields = "id,bay_name,bay_direction,seat_id,cssi,reg,arr_flid,dep_flid,status_flag,remark,del_flag,create_by,create_time,update_by,update_time";

        ApiCallParams apiCallParams = new ApiCallParams();
        apiCallParams.setApiId("10375");
        apiCallParams.setApiType("LIST");
        apiCallParams.setAppKey("200000226");
        apiCallParams.setAppSecret("d43bc101cb3b4add8554f821b568c84c");
        apiCallParams.setApiReturnFields(fields);
        apiCallParams.setListType("LIST");

                apiCallParams.setPageStart(pageStart);
        apiCallParams.setPageSize(pageSize);
        apiCallParams.setOrderByList(orderByList);
        ApiResult apiResult = dataphinService.getDataphinData(apiCallParams);

        if (apiResult.getResultCode() == 200) {
            return JSONObject.parseObject(apiResult.getResultBody());
        } else {
            return JSONObject.parseObject(apiResult.getError());
        }
    }

    /**
     * 施工区域表
     * @param orderByList
     * @param pageStart
     * @param pageSize
     * @return
     */

    @RequestMapping("/data_twin_ads_acis_apron_construction_scop")
    public JSONObject ads_acis_apron_construction_scop(@RequestParam(required = false, defaultValue = "") String orderByList,
                                                      @RequestParam(required = false, defaultValue = "1") Integer pageStart,
                                                      @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        String fields = "id,project_id,name,map_area,influence,status_flag,remark,del_flag,create_by,create_time,update_by,update_time";
        ApiCallParams apiCallParams = new ApiCallParams();
        apiCallParams.setApiId("10378");
        apiCallParams.setApiType("LIST");
        apiCallParams.setAppKey("200000226");
        apiCallParams.setAppSecret("d43bc101cb3b4add8554f821b568c84c");
        apiCallParams.setApiReturnFields(fields);
        apiCallParams.setListType("LIST");

                apiCallParams.setPageStart(pageStart);
        apiCallParams.setPageSize(pageSize);
        apiCallParams.setOrderByList(orderByList);
        ApiResult apiResult = dataphinService.getDataphinData(apiCallParams);

        if (apiResult.getResultCode() == 200) {
            return JSONObject.parseObject(apiResult.getResultBody());
        } else {
            return JSONObject.parseObject(apiResult.getError());
        }
    }

    /**
     * 围栏表
     * @param orderByList
     * @param pageStart
     * @param pageSize
     * @return
     */
    @RequestMapping("/data_twin_ads_acis_apron_fence_df")
    public JSONObject ads_acis_apron_fence_df(@RequestParam(required = false, defaultValue = "") String orderByList,
                                             @RequestParam(required = false, defaultValue = "1") Integer pageStart,
                                             @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        String fields = "id,name,event_desc,start_time,end_time,tool,color,style,send_inside,send_outside,position,end_flag,remark,del_flag,create_by,create_time,update_by,update_time";

        ApiCallParams apiCallParams = new ApiCallParams();
        apiCallParams.setApiId("10379");
        apiCallParams.setApiType("LIST");
        apiCallParams.setAppKey("200000226");
        apiCallParams.setAppSecret("d43bc101cb3b4add8554f821b568c84c");
        apiCallParams.setApiReturnFields(fields);
        apiCallParams.setListType("LIST");

                apiCallParams.setPageStart(pageStart);
        apiCallParams.setPageSize(pageSize);
        apiCallParams.setOrderByList(orderByList);
        ApiResult apiResult = dataphinService.getDataphinData(apiCallParams);

        if (apiResult.getResultCode() == 200) {
            return JSONObject.parseObject(apiResult.getResultBody());
        } else {
            return JSONObject.parseObject(apiResult.getError());
        }
    }

    /**
     *默认滑行路线表
     * @param orderByList
     * @param pageStart
     * @param pageSize
     * @return
     */
    @RequestMapping("/data_twin_ads_apron_taxi_route_default_df")
    public JSONObject ads_apron_taxi_route_default_df(@RequestParam(required = false, defaultValue = "") String orderByList,
                                                     @RequestParam(required = false, defaultValue = "1") Integer pageStart,
                                                     @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        String fields = "id,progress_type,bay,rwy,route_name,route_handle,route_path,route,default_tab,wait_point,remark,del_flag,create_by,create_time,update_by,update_time";

        ApiCallParams apiCallParams = new ApiCallParams();
        apiCallParams.setApiId("10380");
        apiCallParams.setApiType("LIST");
        apiCallParams.setAppKey("200000226");
        apiCallParams.setAppSecret("d43bc101cb3b4add8554f821b568c84c");
        apiCallParams.setApiReturnFields(fields);
        apiCallParams.setListType("LIST");

                apiCallParams.setPageStart(pageStart);
        apiCallParams.setPageSize(pageSize);
        apiCallParams.setOrderByList(orderByList);
        ApiResult apiResult = dataphinService.getDataphinData(apiCallParams);

        if (apiResult.getResultCode() == 200) {
            return JSONObject.parseObject(apiResult.getResultBody());
        } else {
            return JSONObject.parseObject(apiResult.getError());
        }
    }

    /**
     * 标准滑行路线表
     * @param orderByList
     * @param pageStart
     * @param pageSize
     * @return
     */
    @RequestMapping("/data_twin_apron_taxi_route_standard_df")
    public JSONObject apron_taxi_route_standard_df(@RequestParam(required = false, defaultValue = "") String orderByList,
                                                  @RequestParam(required = false, defaultValue = "1") Integer pageStart,
                                                  @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        String fields = "id,progress_type,rwy,route_name,route_path,route_handle,remark,del_flag,create_by,create_time,update_by,update_time";

        ApiCallParams apiCallParams = new ApiCallParams();
        apiCallParams.setApiId("10382");
        apiCallParams.setApiType("LIST");
        apiCallParams.setAppKey("200000226");
        apiCallParams.setAppSecret("d43bc101cb3b4add8554f821b568c84c");
        apiCallParams.setApiReturnFields(fields);
        apiCallParams.setListType("LIST");

                apiCallParams.setPageStart(pageStart);
        apiCallParams.setPageSize(pageSize);
        apiCallParams.setOrderByList(orderByList);
        ApiResult apiResult = dataphinService.getDataphinData(apiCallParams);

        if (apiResult.getResultCode() == 200) {
            return JSONObject.parseObject(apiResult.getResultBody());
        } else {
            return JSONObject.parseObject(apiResult.getError());
        }
    }

    /**
     * 标准滑行路线关联停机位
     * @param orderByList
     * @param pageStart
     * @param pageSize
     * @return
     */
    @RequestMapping("/data_twin_apron_taxi_route_standard_bay_df")
    public JSONObject apron_taxi_route_standard_bay_df(@RequestParam(required = false, defaultValue = "") String orderByList,
                                                       @RequestParam(required = false, defaultValue = "1") Integer pageStart,
                                                       @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        String fields = "id,route_id,bay,create_time";

        ApiCallParams apiCallParams = new ApiCallParams();
        apiCallParams.setApiId("10381");
        apiCallParams.setApiType("LIST");
        apiCallParams.setAppKey("200000226");
        apiCallParams.setAppSecret("d43bc101cb3b4add8554f821b568c84c");
        apiCallParams.setApiReturnFields(fields);
        apiCallParams.setListType("LIST");

                apiCallParams.setPageStart(pageStart);
        apiCallParams.setPageSize(pageSize);
        apiCallParams.setOrderByList(orderByList);
        ApiResult apiResult = dataphinService.getDataphinData(apiCallParams);

        if (apiResult.getResultCode() == 200) {
            return JSONObject.parseObject(apiResult.getResultBody());
        } else {
            return JSONObject.parseObject(apiResult.getError());
        }
    }

    /**
     * 施工计划表
     * @param orderByList
     * @param pageStart
     * @param pageSize
     * @return
     */
    @RequestMapping("/data_twin_ads_acis_apron_construction_df")
    public JSONObject ads_acis_apron_construction_df(@RequestParam(required = false, defaultValue = "") String orderByList,
                                                    @RequestParam(required = false, defaultValue = "1") Integer pageStart,
                                                    @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        String fields = "id,record_id,number,task_key,apply_type,work_name,work_content,project_type,is_high,is_affect_car,is_affect_flight,is_continue_work,is_use_fire,use_fire_start_time,use_fire_end_time,work_depart_id,work_depart,work_start_time,work_end_time,work_affect_area,work_note,work_area,work_type,create_date,work_approve_depart_id,work_approve_depart,approve_route,exit_route,status_flag,constr_area_type,create_from,actual_start_time,actual_end_time,is_paused,remark,del_flag,create_by,create_time,update_by,update_time";

        ApiCallParams apiCallParams = new ApiCallParams();
        apiCallParams.setApiId("10377");
        apiCallParams.setApiType("LIST");
        apiCallParams.setAppKey("200000226");
        apiCallParams.setAppSecret("d43bc101cb3b4add8554f821b568c84c");
        apiCallParams.setApiReturnFields(fields);
        apiCallParams.setListType("LIST");

                apiCallParams.setPageStart(pageStart);
        apiCallParams.setPageSize(pageSize);
        apiCallParams.setOrderByList(orderByList);
        ApiResult apiResult = dataphinService.getDataphinData(apiCallParams);

        if (apiResult.getResultCode() == 200) {
            return JSONObject.parseObject(apiResult.getResultBody());
        } else {
            return JSONObject.parseObject(apiResult.getError());
        }
    }

    /**
     * 缓压机位
     * @param orderByList
     * @param pageStart
     * @param pageSize
     * @return
     */
    @RequestMapping("/data_twin_ads_acis_apron_buffer_stand_df")
    public JSONObject ads_acis_apron_buffer_stand_df(@RequestParam(required = false, defaultValue = "") String orderByList,
                                                    @RequestParam(required = false, defaultValue = "1") Integer pageStart,
                                                    @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        String fields = "id,stand_no,is_closed,polygon,limit_stand,affect_in_stand,affect_out_stand,special_influence,del_flag,create_by,create_time,update_by,update_time";

        ApiCallParams apiCallParams = new ApiCallParams();
        apiCallParams.setApiId("10376");
        apiCallParams.setApiType("LIST");
        apiCallParams.setAppKey("200000226");
        apiCallParams.setAppSecret("d43bc101cb3b4add8554f821b568c84c");
        apiCallParams.setApiReturnFields(fields);
        apiCallParams.setListType("LIST");

                apiCallParams.setPageStart(pageStart);
        apiCallParams.setPageSize(pageSize);
        apiCallParams.setOrderByList(orderByList);
        ApiResult apiResult = dataphinService.getDataphinData(apiCallParams);

        if (apiResult.getResultCode() == 200) {
            return JSONObject.parseObject(apiResult.getResultBody());
        } else {
            return JSONObject.parseObject(apiResult.getError());
        }
    }

}
